feat(collector): support reading config file path from CLI and loading log configuration from config file in Go Collector#2375
Open
empiredan wants to merge 5 commits intoapache:masterfrom
Open
Conversation
…g log configuration from config file in Go Collector
7 tasks
acelyc111-bot
left a comment
There was a problem hiding this comment.
Review: Configurable logging for Go Collector
Summary: Adds CLI flag -config for specifying config file path and moves all log configuration (filename, size, retention, level) into config.yml with proper validation and defaults.
What's good:
- Clean refactoring:
main()is now much more readable withloadConfigs()andsetupLog()extracted - Proper validation for all config values with early
os.Exiton errors - Sensible defaults:
/tmp/collector.log, 64MB, 3 days, 8 files, info level - The
-configflag makes deployment easier (was previously hardcoded asconfig.yml) - Error messages go to stderr before exit — good practice for CLI tools
Minor notes:
setupLog()is a bit long — the repeated pattern ofget option → check ok → validate → set defaultcould be extracted into a small helper likegetConfigInt(options, key, default)to reduce boilerplate- The old code logged to
./pegasus.logbut the new default is/tmp/collector.log— this is a behavioral change that should be noted in release notes (though/tmpis arguably a better default)
Verdict: ✅ Approve — Clean, well-validated config improvement. Ready to merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#2358
This PR adds support for the Go collector to obtain the configuration file path
via command-line arguments.
It also makes log initialization configurable by loading log-related settings from
the configuration file, including the log file path, log level, log retention time, and
the number of retained log files.